package lime.workflow.command;

import lime.workflow.view.WorkitemView;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;

public class AutoRefreshHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		
		Command command = event.getCommand();
		boolean oldValue = HandlerUtil.toggleCommandState(command);

		WorkitemView view = (WorkitemView) HandlerUtil.getActivePart(event);
		view.setAutoRefresh(!oldValue);
		
		return null;
	}
}
